package com.weiqiao.mall.repository;

import com.weiqiao.base.dao.IBaseMongoDao;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.springframework.data.domain.Pageable;

import java.util.List;

public interface ICommentRepository extends IBaseMongoDao {

    /**
     * 新增评论
     *
     * @param json
     * @param company_id
     * @return
     */
    boolean addCommentOne(String json, int company_id);

    /**
     * 新增多条评论
     *
     * @param documents
     * @param company_id
     * @return
     */
    boolean addCommentMany(List<Document> documents, int company_id);

    /**
     * 修改一条评论
     *
     * @param filter
     * @param doc
     * @param flag
     * @param company_id
     * @return
     */
    boolean updateCommentOne(Bson filter, Document doc, boolean flag, int company_id);

    /**
     * 修改多条评论
     *
     * @param filter
     * @param doc
     * @param flag
     * @param company_id
     * @return
     */
    boolean updateCommentMany(Bson filter, Document doc, boolean flag, int company_id);

    /**
     * 根据条件查询一条评论
     *
     * @param filter
     * @param company_id
     * @return
     */
    String findCommentOne(Bson filter, int company_id);

    /**
     * 根据条件查询多条评论
     *
     * @param filter
     * @param company_id
     * @return
     */
    List<String> findCommentMany(Bson filter, int company_id);


    /**
     * 查询评论条数
     */
    int getCount(int company_id, Document doc);

    /**
     * 根据条件查询多条评论,做排序
     *
     * @param company_id
     * @param doc
     * @param pageable
     * @return
     */
    List<String> findCommentPage(int company_id, Bson doc, Pageable pageable);

    /**
     * 删除一条评论
     *
     * @param filter
     * @param company_id
     * @return
     */
    boolean deleteCommentOne(Bson filter, int company_id);

    /**
     * 删除多条评论
     *
     * @param filter
     * @param company_id
     * @return
     */
    boolean deleteCommentMany(Bson filter, int company_id);

    /**
     * 条件查询多条评论并排序分页
     *
     * @param filter
     * @param sort
     * @param limit
     * @param company_id
     * @return
     */
    List<String> findCommentManySortLimit(Bson filter, Bson sort, int limit, int company_id);
}
